<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
    <link th:href="@{/css/bootstrap.css}" rel="stylesheet">
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/css/site.css}" rel="stylesheet">
    <link th:href="@{/css/bootstrap-responsive.css}" rel="stylesheet">
    <link href="https://unpkg.com/bootstrap-table@1.15.3/dist/bootstrap-table.min.css" rel="stylesheet">
    <script th:src="@{/js/jquery.js}"></script>
    <script th:src="@{/js/bootstrap.js}"></script>
    <script th:src="@{/js/html5.js}"></script>
    <script src="https://unpkg.com/bootstrap-table@1.15.3/dist/bootstrap-table.min.js"></script>
</head>
<body>

<!-- Header -->
<div th:replace="fragments/system/header :: header">
    <p>Header todo...</p>
</div>

<!-- content -->
<div class="container-fluid">
    <div class="row-fluid">
        <div th:replace="fragments/system/menu :: menu">
            <p>menu todo...</p>
        </div>
        <div layout:fragment="content">
            <p>Content goes here...</p>
        </div>
    </div>
    <hr>

<!-- footer -->
<footer th:replace="fragments/system/footer :: footer">
        <div>footer todo</div>
    </footer>

</div>

<script>
    // 定义form表单内容转json对象的函数
    (function(window, $) {
        $.fn.serializeJson = function() {
            var serializeObj = {};
            var array = this.serializeArray();
            var str = this.serialize();
            $(array).each(
                function() {
                    if (serializeObj[this.name]) {
                        if ($.isArray(serializeObj[this.name])) {
                            serializeObj[this.name].push(this.value);
                        } else {
                            serializeObj[this.name] = [
                                serializeObj[this.name], this.value ];
                        }
                    } else {
                        serializeObj[this.name] = this.value;
                    }
                });
            return serializeObj;
        };
    })(window, jQuery);

    // 获取下拉框的值
    function selectSelects(name) {
        var selects = "";
        $('#' + name + ' option:selected').each(function (i) {
            if (0 === i) {
                selects = $(this).val();
            } else {
                selects += ("," + $(this).val());
            }
        });
        return selects;
    }

    // 获取复选框的值
    function selectCheckeds(name) {
        var checkeds = "";
        $('input:checkbox[name="' + name + '"]:checked').each(function(i,v) {
            console.log(v);
            debugger
            if (0 == i) {
                checkeds = $(this).val();
            } else {
                checkeds += ("," + $(this).val());
            }
        });
        return checkeds;
    }

    let EmrResultCode = {
        MR_TP_NOT_HAS_PUBLISHED: {message: "病历模板没有发布版本供使用" , code: 1001},
        MR_MULTI_LIMIT: {message: '多例病历创建频率过高，请一分钟后重试', code: 1002},
        MR_SINGLE_LIMIT: {message: '不能重复创建单例病历', code: 1003},
        MR_CONTENT_NOT_LEGAL: {message: '病历内容格式不合法', code: 1004},
        MR_CONTENT_VERSION_NOT_LEGAL: {message: '病历内容版本号不合法', code: 1005},
        MR_CONTENT_FIRST_VERSION_ALREADY: {message: '病历已有内容记录，无法创建首条记录内容', code: 1006},
        MR_CONTENT_NOT_EXITS: {message: '病历记录内容不存在', code: 1007},
        MR_CONTENT_VERSION_NOT_NEWEST: {message: '病历内容完成版本不是最新版本, 无法继续操作', code: 1008},
        MR_CONTENT_COMPLETED_ALREADY: {message: '病历记录内容已经标记完成', code: 1009},
        MR_CONTENT_NOT_COMPLETED: {message: '病历记录内容未完成', code: 1010},
        MR_CONTENT_ACTION_NOT_LEGAL: {message: '动作指令不合法，必须为：0-取消完成，1-完成', code: 1011},
        getMessageByCode: function(code, defaultMsg){
            let message = defaultMsg;
            $.each(EmrResultCode, function(index, value) {
                if(code === value.code) {
                    message = value.message;
                    return false;
                }
            });
            return message;
        }
    }

</script>
</body>
</html>